﻿using Models;
using SoonSheng.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SoonSheng.Controllers
{
    public class HomeController: Controller
    {
        public ActionResult Index()
        {
            ViewBag.mes = "niunan hahaha ...";
            return View();
        }
        public ActionResult MainIndex()
        {
            Headbll hbll = new Headbll();
            List<tbl_main_img>  mglist=hbll.GetMainImgList();
            ViewBag.mainimglist = mglist;
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            List<tbl_product> prodimg= hbll.GetProductImgList();
            ViewBag.prodimglist = prodimg;

            List<tbl_news> newslist= hbll.GetNewList();
            ViewBag.newslist = newslist;
            return View();
        }

        /// <summary>
        /// 获得产品详情
        /// </summary>
        /// <returns></returns>
        public ActionResult ProductDeatil(int prod_id)
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            tbl_product prod=hbll.GetProductByID(prod_id);            
            ViewBag.prod = prod;
            List<tbl_prod_class> prodclass = hbll.GetProductClass();
            ViewBag.prodclass = prodclass;
            return View();
        }
        /// <summary>
        /// 获取同类产品
        /// </summary>
        /// <param name="class_id"></param>
        /// <returns></returns>
        public ActionResult ProductListByType(int class_id)
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            List<tbl_product> prodimg = hbll.GetProductListByClassID(class_id);
            ViewBag.prodimg = prodimg;
            List<tbl_prod_class> prodclass = hbll.GetProductClass();
            ViewBag.prodclass = prodclass;
            return View();
        }
        /// <summary>
        /// 公司介绍(默认获取第一个)
        /// </summary>
        /// <returns></returns>
        public ActionResult CompanyInfoIndex()
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            List<tbl_companyinfo_type> companyinfotype = hbll.GetALLCompanyInfotype();
            tbl_companyinfo_detail companyinfotypedetail = hbll.GetALLCompanyInfotype(1);
            ViewBag.companyinfotype = companyinfotype;
            ViewBag.companyinfotypedetail = companyinfotypedetail;
            return View();
        }
        /// <summary>
        /// 根据公司简介分类得到具体信息
        /// </summary>
        /// <param name="type_id"></param>
        /// <returns></returns>
      
        public ActionResult GetCompanyInfoDeatil(int type_id)
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            tbl_companyinfo_detail companyinfotypedetail = hbll.GetALLCompanyInfotype(type_id);
            return Json(companyinfotypedetail);
        }
        /// <summary>
        /// 产品中心
        /// </summary>
        /// <returns></returns>
        public ActionResult productIndex()
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            List<tbl_product> prodimg = hbll.GetALLProductList();
            ViewBag.prodimg = prodimg;
            List<tbl_prod_class> prodclass = hbll.GetProductClass();
            ViewBag.prodclass = prodclass;
            return View();
        }
        /// <summary>
        /// 服务优势
        /// </summary>
        /// <returns></returns>
        public ActionResult ServiceAdvantageIndex()
        {
           
            return View();
        }
        /// <summary>
        /// 新闻
        /// </summary>
        /// <returns></returns>
        public ActionResult NewsIndex()
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            List<tbl_news_class> newclass = hbll.GetALLNewType();
            ViewBag.newclass = newclass;
            List<tbl_news> newslist = hbll.GetALLNews();
            ViewBag.newslist = newslist;
            return View();
        }

        public ActionResult GetNewListByClassID(int newsclass_id)
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            List<tbl_news_class> newclass = hbll.GetALLNewType();
            ViewBag.newclass = newclass;
            List<tbl_news> newslist = hbll.GetALLNewsByClassID(newsclass_id);
            ViewBag.newslist = newslist;
            return View();
        }

        public ActionResult GetNewsDetail(int news_id)
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            List<tbl_news_class> newclass = hbll.GetALLNewType();
            ViewBag.newclass = newclass;
            tbl_news newsdetail=hbll.GetNewsDeatilByNewsID(news_id);
            ViewBag.newsdetail = newsdetail;
            return View();
        }
        /// <summary>
        /// 服务支持
        /// </summary>
        /// <returns></returns>
        public ActionResult ServiceSupportIndex()
        {
            return View();
        }
        /// <summary>
        /// 联系我们
        /// </summary>
        /// <returns></returns>
        public ActionResult ContactUsIndex()
        {
            Headbll hbll = new Headbll();
            tbl_main_img GetLgoImg = hbll.GetLgoImg();
            ViewBag.logo = GetLgoImg;
            return View();
        }
    }
}